 
#include <iostream>
#include <fstream>
#include <vector>
#include <chrono>
using namespace std;
using namespace std::chrono;

void sort_nums(vector<int>& data) {
    int flag = 1;
    while (flag) {
        flag = 0;
        for (int i = 0; i < data.size() - 1; i++) {
            if (data[i] > data[i + 1]) {
                swap(data[i], data[i + 1]);
                flag = 1;
            }
        }
    }
}

vector<int> read_f(const string& file) {
    ifstream input(file);
    vector<int> data;
    int num;
    while (input >> num) {
        data.push_back(num);
    }
    return data;
}

int main() {
    vector<int> step_1 = read_f("m1_sorted.txt");
    auto time_start = high_resolution_clock::now();
    sort_nums(step_1);
    auto time_finish = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(time_finish - time_start);
    cout << "m1_sorted " << duration.count() << " milliseconds" << endl;

    vector<int> step_2 = read_f("m2_reverse.txt");
    time_start = high_resolution_clock::now();
    sort_nums(step_2);
    time_finish = high_resolution_clock::now();
    duration = duration_cast<milliseconds>(time_finish - time_start);
    cout << "m2_reversed " << duration.count() << " milliseconds" << endl;

    vector<int> step_3 = read_f("m3_shuffle.txt");
    time_start = high_resolution_clock::now();
    sort_nums(step_3);
    time_finish = high_resolution_clock::now();
    duration = duration_cast<milliseconds>(time_finish - time_start);
    cout << "m3_shuffle " << duration.count() << " milliseconds" << endl;

    return 0;
}
